package com.zlp.spring.mybatis;

import com.zlp.spring.mybatis.config.MybatisConfig;
import com.zlp.spring.mybatis.mapper.UserMapper;
import com.zlp.spring.mybatis.service.UserService;
import org.apache.ibatis.session.SqlSession;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;
import java.util.Map;

/**
 * 注解测试类
 * @author Zou.LiPing
 * @date: 2021/2/24 17:13
 */
public class AnnotationMybatisTest {
 

    public static void main(String[] args) {


        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(MybatisConfig.class);

//        UserService userService = ac.getBean(UserService.class);
//        userService.getUserList();

        List<Map<String, Object>> users = ac.getBean(UserMapper.class).getUsers();

        //ac.getBeanFactory().registerSingleton();

//        Class [] interfaces = new Class[]{UserMapper.class};
//        UserMapper userMapper = (UserMapper) Proxy.newProxyInstance(AnnotationMybatisTest.class.getClassLoader(),interfaces,new MyInvocationHandler());
//        userMapper.getUsers();

//        SqlSession sqlSession = null;
//        UserMapper userMapper1 = sqlSession.getMapper(UserMapper.class);

        // 执行流程类
        // org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper
        // org.apache.ibatis.binding.MapperProxyFactory.newInstance(org.apache.ibatis.binding.MapperProxy<T>)


    }
}